package com.tbs.struct.tree.model;

import com.tbs.struct.tree.api.ITreeNode;

import java.util.LinkedList;
import java.util.List;

/**
 * 简单树节点实现
 *
 * @param <K>
 * @param <V>
 * @author abstergo
 */
public class SimpleTreeNode<K, V> implements ITreeNode<K, V> {
    private K key;
    private V value;

    private List<ITreeNode<K, V>> children = new LinkedList<>();

    public SimpleTreeNode(K key, V value, List<ITreeNode<K, V>> children) {
        this.key = key;
        this.value = value;
        this.children = children;
    }

    public SimpleTreeNode(K key, V value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public K getKey() {
        return key;
    }

    @Override
    public V getValue() {
        return value;
    }

    @Override
    public void setValue(V value) {
        this.value = value;
    }

    @Override
    public List<ITreeNode<K, V>> getChildren() {
        return children;
    }

    @Override
    public void setChildren(List<ITreeNode<K, V>> children) {
        this.children = children;
    }
}
